<?php

function num2en($num = 0) {
    $enws=array(
        0=>"zero",1=>"one",2=>"two",3=>"three",4=>"four",
        5=>"five",6=>"six",7=>"seven",8=>"eight",9=>"nine",
        10=>"ten",11=>"eleven",12=>"twelve",
        13=>"thirteen",14=>"fourteen", 15=>"fifteen",
        16=>"sixteen",17=>"seventeen",18=>"eighteen",19=>"nineteen",
        20=>"twenty",30=>"thirty",40=>"forty",50=>"fifty",
        60=>"sixty",70=>"seventy",80=>"eighty",90=>"ninety"
    );
    return $enws[$num];
}

function fieldTypeOpt($val = ''){
    $ret = '<optgroup label="数字">
            <option>tinyint</option>
            <option>smallint</option>
            <option>mediumint</option>
            <option >int</option>
            <option>bigint</option>
            <option>decimal</option>
            <option>float</option>
            <option>double</option>
        </optgroup>
        <optgroup label="日期时间">
            <option>date</option>
            <option>datetime</option>
            <option>timestamp</option>
            <option>time</option>
            <option>year</option>
        </optgroup>
        <optgroup label="字符串">
            <option>char</option>
            <option>varchar</option>
            <option>tinytext</option>
            <option>text</option>
            <option>mediumtext</option>
            <option>longtext</option>
        </optgroup>
        <optgroup label="列表">
            <option>enum</option>
            <option>set</option>
        </optgroup>
        <optgroup label="二进制">
            <option>bit</option>
            <option>binary</option>
            <option>varbinary</option>
            <option>tinyblob</option>
            <option>blob</option>
            <option>mediumblob</option>
            <option>longblob</option>
        </optgroup>';
    return $ret;
}

function fieldCollationOpt($val='')
{
    $str = '<select class="ui mini dropdown" data-value="'.$val.'" >
            <option value="">(校对)</option>
            <optgroup label="常用">
                <option >utf8_general_ci</option>
                <option>gbk_bin</option>
                <option>gb2312_bin</option>
            </optgroup>
            <optgroup label="ascii">
                <option>ascii_bin</option>
                <option>ascii_general_ci</option>
            </optgroup>
            <optgroup label="big5">
                <option>big5_bin</option>
                <option>big5_chinese_ci</option>
            </optgroup>
            <optgroup label="binary">
                <option>binary</option>
            </optgroup>
            <optgroup label="utf8">
                <option>utf8_bin</option>
                <option>utf8_czech_ci</option>
            </optgroup>
        </select>';
    return $str;
}

function createTbFormField($tbInfo = ''){
    F($tbName,$tbInfo,C('ITEM_PATH'));
}

//获取表的表单字段信息
function getTbFormField($tbInfo = '',$c = 'Common'){
    $tbName = $tbInfo['id']['table'];
    $tb = F($tbName,'',C('ITEM_PATH'));
    if ($tb[$c]) return $tb[$c];
    $formInfo = array();
    foreach ($tbInfo as $k) {
        $k['ipttype'] = 'input';
        $k['format'] = 'text';
        $k['isshow'] = 1;
        $k['valid'] = '';
        $formInfo[$c][$k['field']] = $k;
    }
    F($tbName,$formInfo,C('ITEM_PATH'));
    return $formInfo[$c];
}

function getAllForm($tb='')
{
    $tb = F($tbName,'',C('ITEM_PATH'));
    return $tb;
}

function getAllFormScene($tb='')
{
    print_r(C('ITEM_PATH'));exit();
    $tb = F($tb,'',C('ITEM_PATH'));
    $vo = array();
    foreach ($tb as $k=>$v) {
        array_push($vo, $k);
    }
    return $vo;
}

?>
